const colorList = ['#95a2ff', '#fa8080', '#ffc076', '#fae768', '#87e885', '#3cb9fc', '#73abf5', '#cb9bff', '#434348', '#90ed7d']

export default {
  components: {},
  props: {
    echartsWidth: {
      type: Number,
      default: 1200
    },
    echartsHeight: {
      type: Number,
      default: 480
    },
    seriesData: {
      type: Array
    }
  },
  data() {
    return {
      chartInstance: null
    }
  },
  // 在实例创建完成后被立即调用
  created() {

  },
  // 实例被挂在后调用
  mounted() {
    this.init()
  },
  // 方法
  methods: {
    init() {
      this.chartInstance = this.$echarts.init(this.$refs.echartsRef)

      let option = {
        legend: {
          top: 'bottom'
        },
        // 提示工具
        tooltip: {
          trigger: 'item' // 触发类型
        },
        series: [
          {
            type: 'pie',
            radius: [50, 200],
            center: ['50%', '50%'],
            roseType: 'area',
            itemStyle: {
              borderRadius: 8
            },
            data: this.seriesData.sort((a, b) => a.value - b.value)
          }
        ]
      }
      this.chartInstance.setOption(option)
    }
  }
}
